#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int i = 0;
	int j = 0;
	int N = 0;
	int num = 0;
	int count = 0;
	int Max = -1;
	int arr[1000] = { 0 };
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 0; i < N; i++)
	{
		count = 0;
		for (j = 0; j < N; j++)
		{
			if (arr[i] == arr[j])
				count++;
		}
		if (count > Max)
		{
			Max = count;
			num = arr[i];
		}
	}
	printf("%d %d", num, Max);
	return 0;
}

